<?php
/*
CRM 用户QQ类
*/
class Com_crm_log{
	function __construct($ainfo=null){
		$this->model = Afun_db()->model(Acan_table_crm_log);
	}
	function add($note,$type='other',$cid=0){
		$save->uid = Afun_uid();
		$save->cid = $cid;
		$save->type = $type;
		$save->note = $note;
		if(in_array($type,array('add_cus','up_cus','get_pool'))){
			$save->note = $this->$type($note,$cid);
		}
		$save->date = Afun_get_time();
		$this->model->save($save);
	}
	function add_cus($arr){
		$model = Afun_db()->model(Acan_table_crm_customer);
		$str = '';
		foreach ($arr as $key => $val) {
			if($model->comment[$key] && strlen($val)>0)
				$str .= $model->comment[$key].':'.$val.', ';
		}
		return $str;
	}
	function up_cus($arr,$cid){
		$model = Afun_db()->model(Acan_table_crm_customer);
		$old = $model->findPk($cid);
		$str = '';
		foreach ($arr as $key => $val) {
			if($model->comment[$key] && $val != $old[$key])
				$str .= $model->comment[$key].':由 '.$old[$key].' 修改为 '.$val.', ';
		}
		return $str;
	}
	function get_pool($arr){
		
	}
	
}
?>